﻿using CsvHelper;
using EfSandbox.Context;
using EfSandbox.Entities.Final.Common;
using EfSandbox.Entities.Final.Eod;
using EfSandbox.Migrations;
using System;
using System.Data.Entity;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

// http://stackoverflow.com/questions/5940225/fastest-way-of-inserting-in-entity-framework
// https://efbulkinsert.codeplex.com/

namespace EfSandbox {
    class Program {
        static void Main(string[] args) {

            Database.SetInitializer<SandboxContext>(new Initializer());

            using(var context = new SandboxContext()) {
                var e = context.Exchanges.ToList();
                Quote q = new Quote();
                q.Symbol = context.Symbols.Include(t => t.Exchange).SingleOrDefault(s => s.SymbolCode == "ATRS" && s.Exchange.ExchangeCode == "AMS");
                q.TradeDate = DateTime.Now;
                q.Open = 10;
                q.High = 11;
                q.Low = 9;
                q.Close = 10.5M;
                q.Volume = 100;
                q.FrequencyId = 7;
                context.Quotes.Add(q);
                
                context.SaveChanges();
            }

        }
    }
}
